﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Biz_Dal.Biz;

public partial class Trang_web_Trang_thong_tin_ca_nhan : System.Web.UI.Page
{
    BizKhachHang kh=new BizKhachHang();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Khach_hang"] != null)
        {
            PanelThongTinCN.Visible = true;
            Load_KH();
        }
        else
        {
            PanelThongTinCN.Visible = false;
        }

    }


    protected void btnLuu_Click(object sender, EventArgs e)
    {
        kh = BizKhachHang.getKhachHangByID(int.Parse(Ma_KH.Text));
        string matkhau = kh.matKhau;
        if (txtMatKhauMoi1.Text.Trim()!="" && txtMatKhauCu.Text==matkhau)
        {
            matkhau = txtMatKhauMoi1.Text;
        }
        kh.hoTen = txtHoTen.Text.ToString();
        kh.email = txtEmail.Text.ToString();
        //kh.diaChi = txtDiaChi.Text.ToString();
        kh.diaChi = Dia_chi.Value;
        kh.matKhau = matkhau;
        kh.dienThoai = txtDienThoai.Text.ToString();
        kh.taiKhoan = double.Parse(txtTaiKhoan.Text.ToString());
        kh.updateKhachHang();
        PanelMatKhau.Visible = false;
        Load_KH();
    }
    protected void btnDoiMK_Click(object sender, EventArgs e)
    {
        PanelMatKhau.Visible = true;
    }

    private void Load_KH()
    {
        kh = (BizKhachHang)Session["Khach_hang"];
        Ma_KH.Text = kh.idUser.ToString();
        Ten_Dang_Nhap.Text = kh.tenDangNhap;
        txtMatKhauCu.Text = kh.matKhau;
        txtMatKhauMoi1.Text = null;
        txtMatKhauMoi2.Text = null;
        txtHoTen.Text = kh.hoTen;
        txtEmail.Text = kh.email;
        //txtDiaChi.Text = kh.diaChi;
        Dia_chi.Value = kh.diaChi;
        txtDienThoai.Text = kh.dienThoai;
        txtTaiKhoan.Text = kh.taiKhoan.ToString();
    }
}